/***************************************************************************
 *            udpserver_test.c
 *
 *  Mon May 21 22:14:44 2007
 *  Copyright  2007  kf701
 *  Email <kf701.ye AT gmail.com>
 ****************************************************************************/


#include "kf701.h"

int send_sock;

void run(struct sockaddr *addr, uint8_t *data, uint32_t size)
{
	data[size] = 0;
	sys_debug("%s,%d: socket data = %s\n", __FILE__, __LINE__, data);

	uint8_t buf[10];
	rand_string( buf, sizeof(buf) );
	socklen_t len = sizeof( struct sockaddr_in );
	sendto( send_sock, buf, sizeof(buf), 0, addr, len );
}

int main()
{
	debug_verbose = 4;
	sys_debug("udp listen port 8080 ...\n");
	send_sock = socket(AF_INET,SOCK_DGRAM,0);
	udp_server( 8080, 1024, run );
	return 0;
}
